package com.huangyi;

public class Main {
    public static void main(String[] args) {
        class Solution {
            public int findMin(int[] nums) {
                int left = 0, right = nums.length-1,n=nums.length-1;
                while(left<right){
                    int mid = left + (right-left)/2;
                    if(nums[mid] <= nums[n]){
                        right = mid;
                    }else{
                        left = mid + 1;
                    }
                }
                return nums[left];

            }
        }

        class Solution2 {
            public int missingNumber(int[] nums) {
                int left = 0, right = nums.length - 1;
                while (left < right) {
                    int mid = left + (right - left) / 2;
                    if (nums[mid] == mid) {
                        left = mid + 1;
                    } else {
                        right = mid;
                    }
                }
                return left == nums[left] ? left + 1 : left;
            }
        }
    }
}